package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;

@Controller
@RequestMapping("/payment")
public class ImageController {

    @GetMapping(value="/image")
    @ResponseBody
    public void image(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        BufferedImage image= (BufferedImage) req.getSession().getAttribute("image");
        ImageIO.write(image,"JPEG",resp.getOutputStream());
    }
}
